package com.components.headerrecycler

import android.content.Context
import android.util.AttributeSet
import android.view.LayoutInflater
import android.view.View
import android.widget.LinearLayout
import com.components.headerrecycler.R
import com.scwang.smart.refresh.footer.ClassicsFooter
import com.scwang.smart.refresh.layout.SmartRefreshLayout
import com.scwang.smart.refresh.layout.constant.SpinnerStyle

/**
 * @Author LuoKun
 * @Des 统一刷新布局样式
 * 用例：在需要上下刷新的时候统一用这个类，方便管理
 * 该类不对列表怎么展示数据做处理，需要在用的时候自己写
 */
class RefreshHeaderView : LinearLayout {

    private val mContext: Context
    private val mView: View
    var smartRefreshLayout: SmartRefreshLayout
    var recyclerView: HeaderRecyclerView

    constructor(context: Context, attrs: AttributeSet?) : super(context, attrs) {
        this.mContext = context
        mView =
            LayoutInflater.from(mContext).inflate(R.layout.layout_refresh_header_view, this, true)
        smartRefreshLayout = mView.findViewById(R.id.smartRefreshLayout)
        recyclerView = mView.findViewById(R.id.recyclerView)
        setRefreshHeader()
    }

    /**
     * 设置RecyclerView头部刷新样式
     * 设置RecyclerView底部刷新样式
     */
    private fun setRefreshHeader() {
        //设置 Header样式
//        smartRefreshLayout.setRefreshHeader(new ClassicsHeader(mContext).setSpinnerStyle(SpinnerStyle.FixedBehind));
        //设置 Footer样式
        smartRefreshLayout.setRefreshFooter(ClassicsFooter(mContext).setSpinnerStyle(SpinnerStyle.FixedBehind))

    }
}